# -*- coding: utf-8 -*-
__author__ = 'Administrator'
# read ini config for model.py
# conf.ini 存储最后爬取页码

import configparser
import os
currentpath = os.path.dirname(os.path.realpath(__file__))
cfgpath = os.path.join(currentpath, "db", "conf.ini")


class ConfParser:
    conf = configparser.ConfigParser()
    conf.read(cfgpath, encoding="utf-8")

    def get_value(self, key):
        return self.conf.get(section="Counts", option=key)

    def set_value(self, key, value, section="Counts"):
        self.conf.set(section, key, value)
        self.conf.write(open(cfgpath, "r+"))


